***************************************************************************
* The following will merge the weights from the matched dataset with the  *
* BITSurvivalWorkingPWT_TB_update.dta dataset.  						  *
***************************************************************************

cd "INSERT WORKING DIRECTORY HERE"

use "Replication.dta", clear
sort leadid year

merge m:1 leadid using "MatchedData.dta"

drop if _merge~=3

*As should be the case, all observations in the matched dataset are in the master
*dataset.  The reverse is obviously not true.  Drop "pruned" observations from
*the data.

drop _merge

**************************************************************************
* The following will stset the data adjusting for the weights with which *
* each observation is measured.											 *
**************************************************************************

stset endobserv [pweight=weights], id(leadid) fail(fail==1) origin(eindate) enter(time mdy(1,1,1965)) scale(365.25)

save "BITMatched_Final.dta", replace
